<?php

/**
 * @author Samrat Khan & Sadik Sarfaraz - Apr 13, 2013
 */

    require('top.inc.php');
?>
<?php
if(isset($_SESSION['user']) && $_SESSION['user']['utype'] == 1 || $_SESSION['user']['utype'] == 2 || $_SESSION['user']['utype'] == 3 || $_SESSION['user']['utype'] == 4) {
    $sess_cusID = $_SESSION['user']['cus_id'];

    //create new object pass in number of pages and identifier
    $pages = new Paginator(' 50', 'page');
    $total = getCountA('returns', 'returns_id', 'cus_id', $sess_cusID, $db);
    $tots = $total[0]['total'];
    $totals = $pages->set_total($tots);
    $limit = $pages->get_limit();
    
    $rows = selectAllWhereA('returns', $limit, 'cus_id', $sess_cusID, $db);
    
    echo "<h5>Fauty Return Report</h5>";
    echo "<table class=\"row-fluid table table-striped table-bordered\">";
            echo "<tr>";
                echo "<th>";
                    echo $return['serialno'];
                echo "</th>";
                echo "<th>";
                    echo $return['project_id'];
                echo "</th>";
                echo "<th>";
                    echo $return['return_rma'];
                echo "</th>";
                echo "<th>";
                    echo $return['pickuprequestdate'];
                echo "</th>";
                echo "<th>";
                    echo $return['physicallyreceivedate'];
                echo "</th>";
                echo "<th>";
                    echo $return['productid'];
                echo "</th>";
                echo "<th>";
                    echo $return['description'];
                echo "</th>";
                echo "<th>";
                    echo $return['revisionstate'];
                echo "</th>";
                echo "<th>";
                    echo $return['boxno'];
                echo "</th>";
                echo "<th>";
                    echo $return['return_quantity'];
                echo "</th>";
                echo "<th>";
                    echo $return['uom'];
                echo "</th>";
                echo "<th>";
                    echo $return['manufacturingdate'];
                echo "</th>";
                echo "<th>";
                    echo $return['returningstatus'];
                echo "</th>";
                echo "<th>";
                    echo $return['receivedfrom'];
                echo "</th>";
                echo "<th>";
                    echo $return['siteid'];
                echo "</th>";
                echo "<th>";
                    echo $return['warehouse_id'];
                echo "</th>";
                echo "<th>";
                    echo $employee['employeename'];
                echo "</th>";
                echo "<th>";
                    echo $return['docketdate'];
                echo "</th>";
                echo "<th>";
                    echo $return['return_docketnumber'];
                echo "</th>";
                echo "<th>";
                    echo $return['remarks'];
                echo "</th>";
                echo "<th>";
                    echo $return['userid'];
                echo "</th>";
                echo "<th>";
                    echo $return['inserteddate'];
                echo "</th>";
            echo "</tr>";
            
        foreach ($rows as $row) {
            echo "<tr>";
                echo "<td>";
                    echo $row['serialno'];
                echo "</td>";
                echo "<td>";
                    echo getName('projects', 'projectname', 'project_id', $row['project_id'], $db);
                echo "</td>";
                echo "<td>";
                    echo $row['return_rma'];
                echo "</td>";
                echo "<td>";
                    echo $row['pickuprequestdate'];
                echo "</td>";
                echo "<td>";
                    echo $row['physicallyreceivedate'];
                echo "</td>";
                echo "<td>";
                    echo $row['productid'];
                echo "</td>";
                echo "<td>";
                    echo $row['description'];
                echo "</td>";
                echo "<td>";
                    echo $row['revisionstate'];
                echo "</td>";
                echo "<td>";
                    echo $row['boxno'];
                echo "</td>";
                echo "<td>";
                    echo $row['return_quantity'];
                echo "</td>";
                echo "<td>";
                    echo uomBeauty($row['uom'], $db);
                echo "</td>";
                echo "<td>";
                    echo $row['manufacturingdate'];
                echo "</td>";
                echo "<td>";
                    echo getName('returnstatus', 'statusname', 'status_id', $row['returningstatus'], $db);
                echo "</td>";
                echo "<td>";
                    echo $row['receivedfrom'];
                echo "</td>";
                echo "<td>";
                    echo $row['siteid'];
                echo "</td>";
                echo "<td>";
                    echo getName('warehouses', 'warehousename', 'warehouse_id', $row['warehouse_id'], $db);
                echo "</td>";
                echo "<td>";
                    echo getName('employee', 'employeename', 'employee_id', $row['employee_id'], $db);
                echo "</td>";
                echo "<td>";
                    echo $row['docketdate'];
                echo "</td>";
                echo "<td>";
                    echo $row['return_docketnumber'];
                echo "</td>";
                echo "<td>";
                    echo $row['remarks'];
                echo "</td>";
                echo "<td>";
                    echo getName('wms_users', 'username', 'id', $row['userid'], $db);
                echo "</td>";
                echo "<td>";
                    echo $row['inserteddate'];
                echo "</td>";
            echo "</tr>";
        }
    echo "<table>";
    echo $pages->page_links();
} else {
    header("Location: login.php");
}
?>

<?php
    include ('bottom.inc.php');
?>